package com.darrenchan.leetcode;

/**
 * @Desc
 * @Author chenchi03
 * @CreateTime 2020-04-19 18:25
 */
public class QLint608 {
    public int[] twoSum(int[] nums, int target) {
        if(nums == null || nums.length <= 1) {
            return null;
        }

        int i = 0, j = nums.length - 1;
        while(i < j) {
            if(nums[i] + nums[j] == target) {
                return new int[]{i + 1, j + 1};
            } else if (nums[i] + nums[j] < target) {
                i++;
            } else {
                j--;
            }
        }
        return null;
    }
}
